from PySide6.QtWidgets import QApplication, QWidget, QVBoxLayout, QCompleter, QLineEdit
import sys
from PySide6.QtGui import QIcon
from PySide6.QtCore import Qt
import config_json
class Window(QWidget):
    def __init__(self):
        super().__init__()
 
        self.setWindowTitle("PySide6 Completer")
        self.setGeometry(300,200,300,250)
 
        
        self.createCompleter()
        self.setIcon()
        self.show()
 
 
 
    def setIcon(self):
        appIcon = QIcon("icon.png")
        self.setWindowIcon(appIcon)
 
 
    def createCompleter(self):
        vbox = QVBoxLayout()
 
        # names = ["Afghanistan", "Argentina", "India", "Pakistan", "Japan", "Indonesia", "China", "UAE", "America",
        #          "Armanistan", "Azerbaijan", "Chicago", "Chile"]
        names=config_json.setting["ffbh"]
        completer = QCompleter(names)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        completer.setFilterMode(Qt.MatchFlag.MatchContains)
        self.lineEdit = QLineEdit()
        self.lineEdit.setCompleter(completer)
        vbox.addWidget(self.lineEdit)
 
        self.setLayout(vbox)
 
 
 
 
config_json.read_setting()
myapp = QApplication(sys.argv)
window = Window()
myapp.exec()
sys.exit()